var express = require('express');
var router = express.Router();
//引入mongodb模块，获得客户端对象
var MongoClient = require('mongodb').MongoClient;
//连接字符串
var DB_CONN_STR = 'mongodb://localhost:27017/notes';
//定义函数表达式，用于操作数据库并返回结果
var insertData = function(db, callback) {
    //获得指定的集合
    var collection = db.collection('notes_list');
    //插入数据
    var data = [{_id:7,"name":'rose',"age":21},{_id:8,"name":'mark',"age":22}];
    collection.insert(data, function(err, result) {
        //如果存在错误
        if(err)
        {
            console.log('Error:'+ err);
            return;
        }
        //调用传入的回调方法，将操作结果返回
        callback(result);
    });
}
/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: req.param('title')+req.param('content') });
});

module.exports = router;
